﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
using System.Threading;
using VisionAbout;
using BaseVisual;
using System.IO;

namespace Can_Test.窗体界面
{
    public partial class Login_NoSQL : Form
    {
        public static string user_name;
        public static string Mode;
        public static int Test_item;
        BaseClass1 BC1 = new BaseClass1();




        public static string CBIndex;

        public Login_NoSQL()
        {
            InitializeComponent();

        }




        private void Login_NoSQL_Load(object sender, EventArgs e)
        {
            try
            {

                ReadData();
                this.comboBox1.SelectedIndex = 0;
                comboBox2.SelectedIndex = 0;


            }
            catch (Exception) { }



        }
        private void button1_Click(object sender, EventArgs e)
        {
            string Str1 = comboBox1.Text.ToString();

            //if (comboBox2.Text != "")
            //{
            switch (Str1)
            {
                case "操作员":
                    if (textBox2.Text == "1")
                    {
                        user_name = comboBox1.Text.Trim();
                        Mode = comboBox2.Text.Trim();
                        Test_item = comboBox2.SelectedIndex;
                        FrmMain form1_1 = new FrmMain();
                        form1_1.Show();
                        this.Hide();


                    }
                    else
                    {
                        MessageBox.Show("密码错误，请重新输入", "提示信息");
                    }
                    break;

                case "工程师":
                    if (textBox2.Text == "123")
                    {
                        user_name = comboBox1.Text.Trim();
                        Mode = comboBox2.Text.Trim();
                        Test_item = comboBox2.SelectedIndex;
                        FrmMain form1_1 = new FrmMain();
                        form1_1.Show();
                        this.Hide();

                    }
                    else
                    {
                        MessageBox.Show("密码错误，请重新输入", "提示信息");
                    }
                    break;
                case "管理员":
                    if (textBox2.Text == "888")
                    {
                        user_name = comboBox1.Text.Trim();
                        Mode = comboBox2.Text.Trim();
                        Test_item = comboBox2.SelectedIndex;
                        FrmMain form1_1 = new FrmMain();
                        form1_1.Show();
                        this.Hide();

                    }
                    else
                    {
                        MessageBox.Show("密码错误，请重新输入", "提示信息");
                    }
                    break;
            }
            Mode = comboBox2.Text.ToString();
            //}

            //else
            //{
            //    MessageBox.Show("请选择测试模式", "提示信息");
            //}





        }

        private void button2_Click(object sender, EventArgs e)
        {
            System.Environment.Exit(0);
        }

        private void textBox2_Click(object sender, EventArgs e)
        {
            // Process.Start(@"C:\Windows\system32\osk.exe");

            textBox2.Focus();
        }

        private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                this.button1.Focus();
                this.button1.PerformClick();//输入密码后按回车键直接登录
            }
        }

        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            CBIndex = comboBox2.Text.Trim();
        }

        private void ReadData()
        {
            string[] filePaths = Directory.GetFiles(BC1.RecipePath);
            string[] Nmae = new string[filePaths.Length];
            for (int i = 0; i < filePaths.Length; i++)
            {
                Nmae[i] = Path.GetFileNameWithoutExtension(filePaths[i]);
            }
            for (int i = 0; i < Nmae.Length; i++)
            {
                comboBox2.Items.Add(Nmae[i]);
            }
        }
    }
}
